<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'foreach.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	<style type="text/css">
		.odd{
			background-color:red;
		}
		.even{
			background-color:green;
		}
	</style>
  </head>
  
  <body>
    <%
    	List list = new ArrayList();
    	list.add("tom");
    	list.add("jerry");
    	list.add("jack");
    	list.add("rose");
    	request.setAttribute("list", list);
     %>
     <table border="1">
     		<tr>
  	  			<th>姓名</th>
  	  			<th>索引</th>
  	  			<th>计数</th>
  	  			<th>当前是否是第一个元素</th>
  	  			<th>当前是否是最后一个元素</th>
  	  		</tr>
  	  		<c:forEach items="${list }" var="name" varStatus="st">
  	  			<tr class="${pageScope.st.index%2==0?"even":"odd"}">
  	  				<td>${pageScope.name }</td>
  	  				<td>${pageScope.st.index }</td>
  	  				<td>${pageScope.st.count }</td>
  	  				<td>${pageScope.st.first }</td>
  	  				<td>${pageScope.st.last }</td>
  	  			</tr>
  	  		</c:forEach>
  	  	  </table>	
  	  		<hr>
  	  		<a href="#">上一页</a>
  	  		<c:forEach begin="1" end="10" step="1" var="num">
  	  			${pageScope.num }
  	  		</c:forEach>
  	  		<a href="#">下一页</a>
   
  </body>
</html>
